<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="../lib/layui/css/layui.css">
  <link rel="stylesheet" href="../styles/css/index.css">
  <script src="../lib/layui/layui.js"></script>
</head>

<body>
  <div class="content">
    <div class="w-title"><span class="w-blueline"></span>专家添加</div>
    <form class="layui-form" action="">
      <div class="layui-row">
        <div class="layui-col-md6">
          <div class="layui-form-item">
            <label class="layui-form-label">专家姓名</label>
            <div class="layui-input-block">
              <input type="text" name="title" required lay-verify="required" placeholder="请输入专家姓名" autocomplete="off"
                class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-col-md6">
          <div class="layui-form-item">
            <label class="layui-form-label">专家等级</label>
            <div class="layui-input-block">
              <select name="city" lay-verify="required">
                <option value="0">普通</option>
                <option value="1">农场B</option>
              </select>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-row">
        <div class="layui-col-md6">
          <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">专家简介</label>
            <div class="layui-input-block">
              <textarea name="desc" placeholder="请输入内容" class="layui-textarea" required
                lay-verify="required"></textarea>
            </div>
          </div>
        </div>
        <div class="layui-col-md6">
          <div class="layui-form-item">
            <label class="layui-form-label">专家照片</label>
            <button type="button" class="layui-btn btn" id="test1">
              <i class="layui-icon">&#xe67c;</i>上传照片
            </button>
          </div>
        </div>
      </div>
      <div class="layui-row">
        <div class="layui-col-md4">
          <span>&nbsp;</span>
        </div>
        <div class="layui-col-md4">
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
              <button type="reset" class="layui-btn layui-btn-primary">取消</button>
            </div>
          </div>
        </div>
        <div class="layui-col-md4">
          <span>&nbsp;</span>
        </div>
      </div>
    </form>
  </div>
</body>

</html>
<script>
  layui.use('form', function () {
    var form = layui.form;
    //监听提交
    form.on('submit(formDemo)', function (data) { //提交事件回调
      layer.msg(JSON.stringify(data.field));
      return false;
    });
  });
  layui.use('upload', function () { // 上传
    var upload = layui.upload;
    //执行实例
    var uploadInst = upload.render({
      elem: '#test1' //绑定元素
        ,
      url: '/upload/' //上传接口
        ,
      multiple: true, // 是否支持多图片上传
      done: function (res) {
        //上传完毕回调
      },
      error: function () {
        //请求异常回调
      }
    });
  });
</script>